{extend name="public:_base" /}

{block name="js"}
{include file="public/_validform"}
<script type="text/javascript">
    $('.cc input').bind('input propertychange', function(){
        var total = 0;
        $(".score").each(function(){
            total+=(parseFloat($(this).val())?parseFloat($(this).val()):0);
        });
        /*total=total.toFixed(1);保留小数点后一位，因为js累加可能会出现小数点后出现多位的情况，可以通过它控制小数点位数*/
        $("#span").text(total);

        $("#score").val( total + {$count??'0'});

    });
    </script>
{/block}
{block name="main"}

<div class="page-container mt-5 cc">

    <form class="form form-horizontal" action="{:url(\''.\\think\\Request::instance()->controller().'/countsave')}" id="form" method="post">

        <table class="layui-table" style="margin-top: 20px;">
            <thead>
                <tr>
                    <th width="10%">序号</th>
                    <th width="20%">问答题目</th>
                    <th width="10%">正确答案</th>
                    <th width="10%">回答问题</th>
                    <th width="10%">本题得分</th>
                </tr>
            </thead>

            <tbody>
                {volist name="list" id="answer"}
                <tr>
                    <td>{$i}</td>
                    <td>{$answer['question']['name']}</td>
                    {neq name="$answer['question']['type']" value="2"}
                    <td>{$answer['question']['answer']}</td>
                    {else/}
                    <td>
                        <label style="font-size: 14px;position: relative;top: 2px;">问答题评分:</label>
                        <input class="score" placeholder="请填写分数" name="contentscore[{$answer['question']['id']}]" value="{$answer['contentscore']??0}" type="number" style="font-size: 16px;">
                    </td>
                    {/neq}
                    <td>{$answer['answer']??'<b style="color: #be191f ">放弃填写</b>'}</td>
                    <td>{$answer['question']['point']??''}</td>
                </tr>
                {/volist}
            </tbody>
        </table>

        <div class="kaoshi-count">

            <div class="kaoshi-count-title">
                {empty name="type"}
                {$an.username}的分数 <input id='score' type="number" class="input-text" value="{$an.score ?? '0'}" disabled placeholder="评分"  name="score">
                {else}
                正在为：{$an.username}评分
            </div>

            <div class="kaoshi-count-txt">
                选择题多选题:{$count} + 自由答题分数
                <input id="count" type="hidden" class="input-text" value="{$count ?? '0'}" >
                <span id="span"></span>
                =
                <input id='score' type="number" class="input-text" value="{$an.score ?? '0'}" placeholder="评分"  name="score">
                <input name="qid" value="{$an.qid}"  type="hidden" />
                <input name="id" value="{$an.id}"  type="hidden" />
                {:token()}
                        <input class="btn radius btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                        <input class="btn radius btn-default radius" type="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;">
                <!-- <button onClick="layer_close();" class="btn radius btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button> -->
            </div>
            {/empty}

        </div>

    </form>
</div>
{/block}